<template>
    <view class="store-tab">
        <view class="tab-item" @tap="onSelect($event, { url: item.url, type: item.type })" :data-url="item.url" :data-type="item.type" v-for="(item, index) in list" :key="index">
            <view class="tab-item-img">
                <image :src="'https://pangguaserve.hunge.vip/imgs/goods/' + item.type + '.png'"></image>
            </view>

            <view :class="'tab-item-text tab-item-text-' + (selected == item.type ? 'selected' : '')">{{ item.name }}</view>
        </view>
    </view>
</template>

<script>
// components/numinput/numinput.js
const app = getApp();
export default {
    data() {
        return {};
    },
    /**
     * 组件的属性列表
     */
    props: {
        list: {
            //数量
            type: Array,
            default: () => [
                {
                    name: '店铺',
                    type: 'store',
                    url: '/pages/store/index'
                },
                {
                    name: '分类查',
                    type: 'collect',
                    url: '/pages/store/type/index'
                },
                {
                    name: '店铺信息',
                    type: 'serve',
                    url: '/pages/store/about/index'
                }
            ]
        },
        selected: {
            //
            type: String,
            default: 'store'
        }
    },
    /**
     * 组件的方法列表
     */
    methods: {
        onSelect(e, _dataset) {
            
            if (!e.currentTarget) {
                if (_dataSet.tagId) {
                    e.currentTarget = {
                        id: _dataSet.tagId
                    };
                } else {
                    e.currentTarget = {
                        dataset: _dataSet
                    };
                }
            }
            
            let url = e.currentTarget.dataset.url;
            let type = e.currentTarget.dataset.type;

            if (type + '' != this.selected + '') {
                uni.redirectTo({
                    url: url
                });
            }
        }
    }
};
</script>
<style>
@import './index.css';
</style>
